<%--
 *  File:   ZylEmployeeCollateConfirm.jsp
 *  Desc:	the Lend slip summary page
 *
 *  Date		  Author		  Changes
 *  2011-11-22	  gengan		  Created
 *
 *  Copyright (C) 2000 - 2012 Oval Technologies, Inc
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%
  //init param
  String strModuleName = "COM";
  String privilegeCode = "A0705";
  String contextPath = request.getContextPath();
%>
<%@ include file="/inc/CommonHeader.inc" %>
<%@ include file="/inc/OvalLocationDefault.inc" %>

<html>
<head>
<title>EmployeeCollateSummary</title>
<PageFlow:CheckPageFlow pageName="p_employeecollateconfirmsummary"/>
<%
	String issalesman = (String)((HashMap)session.getAttribute("userinfo")).get("issalesman");
   Vector summary = (Vector)pageContext.getAttribute("totalsummary");
   if(summary == null)summary = new Vector();
%>
<%@ include file="/inc/CatchError.inc" %>
<%@ include file="/inc/SumDiv.inc" %>
<%@ include file="/rpt/ReportURL.inc" %>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/SummaryDivision.js"></script>
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/Calendar.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/FuncLib.js"></script>
<script type="text/javascript" src="<%=contextPath%>/js/opal2/mootools.js"></script>
<%@ include file="/inc/NewCalendar.inc" %>
<script language="JavaScript">
function page_summary(actionvalue,orderbyname){
	var editform = summaryPrepare(cform,actionvalue,orderbyname);
	if(!editform) return;
	editform.action = "ZylEmployeeCollateConfirm.jsp?<%= OvalTools.randomURL() %>";
	editform.target = "_self";
	isRunning = true;
	editform.submit();
 }
//salesman
function popRep() {
	var regionid=cform.regionid.value;
	var proviceofficecode = document.cform.proviceofficelist.value;
	var businessareacode = document.cform.businessarealist.value;
	var status = "height=400, width=600, top=100, left=100, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no";
	var url = "<%=contextPath%>/tdr/dataverify/SalesPopWindow.jsp?<%= OvalTools.randomURL() %>&regionid="+regionid+"&proviceofficecode="+proviceofficecode+"&businessareacode="+businessareacode;
  
	popwindow = window.open(url, "newwindow", status);
  }

function SetSalesMan(id,code,name){
	cform.userids.value=id;
	cform.employeecode.value=code;
	cform.employeename.value=name;
}

//getsecond 
function page_getpriviceoffice(){
	var objdeptcode=eval("cform.regionid");
	if (objdeptcode==""){
	    return;
	}
	var  datahandler = new  DataHandler();
	datahandler.add_params("regionid" , objdeptcode.value , "Integer");
	datahandler.getResultFromVector("resultproviceoffice","proviceofficename","proviceofficecode","document.cform.proviceofficelist");
	datahandler.add_job("j_zylbusinessareainfobuystock");
	datahandler.runDataHandler();
  }



function page_getbusinessarea(){
	var objdeptcode=eval("cform.proviceofficelist");
	var regionid = document.cform.regionid.value;
	if (objdeptcode==""){
	    return;
	}
	var  datahandler = new  DataHandler();
	datahandler.add_params("regionid" , regionid , "Integer");
	datahandler.add_params("proviceofficelist" , objdeptcode.value , "String");
	datahandler.getResultFromVector("resultbusinessarea","businessareaname","businessareacode","document.cform.businessarealist");
	datahandler.add_job("j_zylbusinessareainfobuystock");
	datahandler.runDataHandler();
 }
//clear text value
function page_clear(){
	document.cform.regionid.value="";
	document.cform.proviceofficelist.value="";
	document.cform.businessarealist.value="";
	document.cform.employeename.value="";
	
	document.cform.serdealercode.value="";
	document.cform.sercustomercode.value="";
	document.cform.serprodcode.value="";
	document.cform.serassignercode.value="";
	document.cform.seremployeecode.value="";
	document.cform.serdealername.value="";
	document.cform.sercustomername.value="";
	document.cform.serprodname.value="";
	document.cform.serassignername.value="";
	document.cform.seremployeename.value="";
	
	
}
function checkAll()
{
     if(cform.selorgids){
        if(cform.selorgids.length){
            for(var i=0;i<cform.selorgids.length;i++) {
                 cform.selorgids[i].checked=cform.selectall.checked;
            }
        }else {
            cform.selorgids.checked=cform.selectall.checked;
        }
     }
}
function checkstatus(){
	
	  var ckorgs = document.getElementsByName("selorgids");
	  if(isNullChecked(cform.selorgids)==true)
	   {
	       alert("<%= message.getMessageDesc("PLEASE_SELECT") %>");
	       return false;
	   }
	  for(var i=0;i<ckorgs.length;i++) {
		if(ckorgs[i].checked && eval("cform.status"+i+".value")==1){
				alert(" 状态为 未分配 的记录不能修改！");
				return false;
		    }
		}
		return true;
    }

function returnstrid(){
	var ckorgs = document.getElementsByName("selorgids");
	var idstr = "";
	for(var i = 0 ; i < ckorgs.length;i++){
		if(ckorgs[i].checked){
			idstr += "," + ckorgs[i].value ;
		}
	}
	var ids = idstr.substring(1);
	document.cform.employeecollateids.value=ids;

}
function auditEmployeeCollate(flag){
	if(!checkstatus())return;
	var ckorgs = document.getElementsByName("selorgids");
	var idstr = "";
	for(var i = 0 ; i < ckorgs.length;i++){
		if(ckorgs[i].checked){
			idstr += "," + ckorgs[i].value ;
		}
	}
	var ids = idstr.substring(1);
	document.cform.employeecollateids.value=ids;
	if(flag=="y"){
		document.cform.flag.value="y";
	}
	if (flag=="n"){
		document.cform.flag.value="n";
	}
	document.cform.actionname.value = "audit";
	document.cform.target="_self";
	isRunning = true;
	document.cform.submit();
	
}
function changecategorycode(){
	
	var categoryIndex = cform.categoryid.options[cform.categoryid.selectedIndex].value;
	if(categoryIndex =="" || categoryIndex==null)cform.categorycode.value=null;
	if(categoryIndex == 4 )cform.categorycode.value = "001";
	if(categoryIndex == 5 )cform.categorycode.value = "002";
	
}
function onLoad(){
	<%
	String strcatid = "";
	if(pageContext.getAttribute("categoryid")=="" || pageContext.getAttribute("categoryid")==null){
		strcatid = "-1";
	}else{
		strcatid = (Integer)pageContext.getAttribute("categoryid")+"";
	}
	%>
	<%if(strcatid.equals("4")){%>
	cform.categoryid.options[1].selected=true;
	<%}else if(strcatid.equals("5")){%>
	cform.categoryid.options[2].selected=true;
	<%}else{%>
	cform.categoryid.options[0].selected=true;
	<%}%>
	}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" onload="onLoad();">
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
<input type="hidden" name="pagename" value="p_employeecollateconfirmsummary">
<input type="hidden" name="actionname">
<input type="hidden" name="portname"> 
<input type="hidden" name="employeecollateids"> 
<custom:hidden property="categorycode" />
<input type="hidden" name = "flag" value="1"/>
<custom:hidden property="businesstype"/>
<%@ include file="/inc/PageLocation.inc" %>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
  <tr>
    <td>
      <table width="100%" border="0" cellspacing="0" onkeydown="if(event.keyCode==13) page_summary('search');">
        
		<tr>
	        <td class="td_right" width="9%"><%= "经销商编码" + label.getLabelName("L_Colon") %></td>
            <td class="td_left" width="11%">
                <custom:text property="serdealercode" size="15" />
			</td>
			<td class="td_right" width="9%"><%= "非锁客户编码" + label.getLabelName("L_Colon") %></td>
            <td class="td_left" width="11%">
                <custom:text property="sercustomercode" size="15" />
			</td>
			<td class="td_right" width="9%"><%= "产品编码" + label.getLabelName("L_Colon") %></td>
            <td class="td_left" width="11">
                <custom:text property="serprodcode" size="15" />
			</td>
			<td class="td_right" width="9%"><%= "分配人工号" + label.getLabelName("L_Colon") %></td>
            <td class="td_left" width="11%">
                <custom:text property="serassignercode" size="15" />
			</td>
			<td class="td_right" width="9%"><%= "代表工号" + label.getLabelName("L_Colon") %></td>
            <td class="td_left" width="11%">
                <custom:text property="seremployeecode" size="15" />
			</td>
        </tr>
		<tr>
			<td class="td_right"><%= "经销商名称" + label.getLabelName("L_Colon") %></td>
            <td class="td_left">
                <custom:text property="serdealername" size="15" />
			</td>
			<td class="td_right"><%= "非锁客户名称" + label.getLabelName("L_Colon") %></td>
            <td class="td_left">
                <custom:text property="sercustomername" size="15" />
			</td>
			<td class="td_right"><%= "产品名称" + label.getLabelName("L_Colon") %></td>
            <td class="td_left">
                <custom:text property="serprodname" size="15" />
			</td>
			<td class="td_right"><%= "分配人名称" + label.getLabelName("L_Colon") %></td>
            <td class="td_left">
                <custom:text property="serassignername" size="15" />
			</td>
			<td class="td_right"><%= "代表名称" + label.getLabelName("L_Colon") %></td>
            <td class="td_left">
                <custom:text property="seremployeename" size="15" />
			</td>
        </tr>
          <% 
	                if(!"Y".equals(issalesman)){
	       %> 
         <tr>
        	    <td class="td_right"><%=label.getLabelName("L_Businessarea") +  label.getLabelName("L_Colon") %></td>
        	  	<td class="td_left"><custom:select property="regionid" optionInnerTextKey="regionname" style="width:160px" optionsName="resultregion" optionValueKey="regionid" onchange="page_getpriviceoffice()" defaultValue="ALL" defaultValueCost=""/></td>
        	    <td class="td_right"><%=label.getLabelName("L_ProvinceOffice") +  label.getLabelName("L_Colon") %></td>
				<td class="td_left">
					<custom:select property="proviceofficelist" optionInnerTextKey="proviceofficename" optionsName="resultproviceoffice" optionValueKey="proviceofficecode" defaultValue="----------" style="width:150px" defaultValueCost="" onchange="page_getbusinessarea();"/>
		        </td>
			    <td  class="td_right"><%=label.getLabelName("L_BusinessAreaName") +  label.getLabelName("L_Colon") %></td>
				<td  class="td_left">
				<custom:select property="businessarealist" optionInnerTextKey="businessareaname" optionsName="resultbusinessarea" optionValueKey="businessareacode" defaultValue="----------" style="width:180px" defaultValueCost=""/> </td>
        	     <td class="td_right"><%=label.getLabelName("L_BusinessContact") +  label.getLabelName("L_Colon") %></td>
				<td><custom:text property="employeename" size="20" readonly="true" style="border:1px #7F9DB9 solid;"/><a onClick="javascript:popRep();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a> 
			    <custom:hidden property="userids"/>
			    <custom:hidden property="employeecode"/>
		        </td>
				<td><button type="button" onclick="page_clear()" class="button1" name="re" value="clear" style="width:60"><%=label.getLabelName("L_Clear") %></button></td>
        	</tr>
        	<% }%>
		<tr>
			
			<td class="td_right" ><%=label.getLabelName("L_Year1") +  label.getLabelName("L_Colon") %></td>
	        <td class="td_left"><custom:selectdic property="years" dictType="Years" command="notnull" label="L_Year1"/></td>
	        <td class="td_right"><%=label.getLabelName("L_Month") +  label.getLabelName("L_Colon") %></td>
	        <td class="td_left"><custom:selectdic property="months" dictType="Months" command="notnull" label="L_Month"/></td>
			<td class="td_right"><%=label.getLabelName("L_ProdCategory") +  label.getLabelName("L_Colon") %></td>
			<td class="td_left"><custom:selectdic property="categoryid" dictType="PatentOrPopular" value="4,5" defaultValueCost=" " defaultValue="-----------" onchange="changecategorycode();"></custom:selectdic></td>
			<td class="td_right"><%= "状态" + label.getLabelName("L_Colon") %></td>
            <td class="td_left" colspan="7">
				<custom:selectdic dictType="AssignStatus" property="serstatus" defaultValue="------" defaultValueCost=""/>
				&nbsp;&nbsp;
				<a href="javascript:page_summary('search')"><img src="/oval/images/cn/go.gif" border="0" ></a>
			</td>
			<td class="td_left">&nbsp; </td>
			<td class="td_right">&nbsp;</td>
			<td class="td_right">&nbsp;</td>
			<td class="td_left">&nbsp;</td>
			<td width="*" colspan="7">&nbsp;</td>
		</tr>
      </table>
    </td>
  </tr>
  <tr>
	<td colspan="2">
      <div style="width:100%;height=400;overflow=auto;">
      <table width="110%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
        <tr class="deepblue-left"> 
          <td width="1%" class="title_center"><input type="checkbox" name="selectall" onclick="checkAll()" style="border:0"></td>
          <td class="title_center">经销商</td>
          <td colspan="2" class="title_center">非锁客户</td>
          <td class="title_center">产品</td>
		  <td class="title_center">销售数量</td>
          <td class="title_center">代表</td>
          <td class="title_center">业务区域</td>
		  <td class="title_center">分配人</td>
		  <td class="title_center">分配时间</td>
          <td class="title_center">审核时间</td>
		  <td class="title_center">状态</td>
        </tr> 
        <tbody> 
          <%
            int i=0;
            String strChecked = "";
            String strClassType = "none";
            boolean bHasChecked = false;
          %>
          <logic:iterate id="onerow" collection="<%= summary %>">
          <%
            if(i%2 == 1){
              strClassType = "td-listrom";
            }else{
              strClassType = "none";
            }
            i++;
          %>
          <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'" onClick="radiotrue('radio<%=JspHelper.filterNull( i )%>')" class="<%=JspHelper.filterNull( strClassType )%>">
            <td><custom:checkbox property="employeecollateid" name="onerow" changedName="selorgids" style="border:0"/><custom:hidden name="onerow" property="status" colIndex="<%=new Integer(i-1) %>"/></td>
            <td><custom:write name="onerow" property="dealercode" nbsp="true"/>&nbsp;&nbsp;<custom:write name="onerow" property="dealername" nbsp="true"/></td>
            <td colspan="2"><custom:write name="onerow" property="customercode" nbsp="true"/>&nbsp;&nbsp;<custom:write name="onerow" property="customername" nbsp="true"/></td>
            <td><custom:write name="onerow" property="prodcode" nbsp="true"/>&nbsp;&nbsp;<custom:write name="onerow" property="prodname" nbsp="true"/></td>
			<td><custom:write name="onerow" property="salesqty" nbsp="true"/></td>
             <td><custom:write name="onerow" property="employeecode" nbsp="true"/>&nbsp;&nbsp;<custom:write name="onerow" property="employeename" nbsp="true"/></td>
            <td><custom:write name="onerow" property="areaname" nbsp="true"/></td>			
			<td><custom:write name="onerow" property="assignername" nbsp="true"/></td>
			<td><custom:write name="onerow" property="assigndate" dataType="date" dataFormat="yyyy-MM-dd HH:mm:ss" nbsp="true"/></td>
			<td><custom:write name="onerow" property="commitdate" dataType="date" dataFormat="yyyy-MM-dd HH:mm:ss" nbsp="true"/></td>
            <td><custom:write name="onerow" property="status" nbsp="true" dictType="AssignStatus"/></td>
          </tr>
          </logic:iterate>
        </tbody> 
        <tfoot> 
	        <tr>
			  <td colspan="2">&nbsp;</td>
			  <td style="text-align:right"><%="本月非锁销量合计" +  label.getLabelName("L_Colon")%></td>
			  <td class="red"><b><custom:write name="hashcounts" property="counts" nbsp="true" dataType="number" dataFormatName="qtyviewformat" nbsp="true"/></b></td>
			  <td style="text-align:right"><%="合计" +  label.getLabelName("L_Colon")%></td>
			  <td class="red"><b><custom:write name="hashsumsqty" property="sumsalesqty" nbsp="true" dataType="number" dataFormatName="qtyviewformat" nbsp="true"/></b></td>
			  <td colspan="6">&nbsp;</td>
	          <%@ include file="/inc/SummaryAction.inc" %>
	          </td>
	        </tr>
	        </tfoot> 
      </table>
	  </div>
    </td>
  </tr>
  <%
  	if(summary.size()>0){
  %>
  <tr>
	<table width="100%" cellspacing="0" cellpadding="0" border="0">
		<tr>
			<td class="td_center" colspan="100">
			   <a onClick="auditEmployeeCollate('y');"><custom:button type="1" label="L_SubmitPost" imgsrc="back.gif" border="0" style="width:80" /></a>
			   &nbsp;&nbsp;
			   <a onClick="auditEmployeeCollate('n');"><custom:button type="1"  value="审核不通过" imgsrc="back.gif" border="0" style="width:80"/></a>
			</td>
		</tr>
	</table>
  </tr>
  <%} %>
 </table>
 </form>
</body>
</html>